]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
test-recorder: Create the recorder only after the stage is realized
authorRui Matos <tiagomatos@gmail.com>
Wed, 2 May 2012 14:23:28 +0000 (16:23 +0200)
committerRui Matos <tiagomatos@gmail.com>
Thu, 3 May 2012 07:27:53 +0000 (09:27 +0200)
The recorder needs the stage's XID so it can only be created after the
stage is realized.

https://bugzilla.gnome.org/show_bug.cgi?id=675301

src/test-recorder.c

index c223bf1149bc599f989725e6d1e06dd08524eaf5..1a8109f4ce0e43976d45332189981bb8cf678d62 100644 (file)
@@ -7,12 +7,19 @@
 /* Very simple test of the ShellRecorder class; shows some text strings
  * moving around and records it.
  */
-static ShellRecorder *recorder;
+static ShellRecorder *recorder = NULL;
 
 static gboolean
 stop_recording_timeout (gpointer data)
 {
-  shell_recorder_close (recorder);
+  if (recorder)
+    {
+      shell_recorder_close (recorder);
+      g_object_unref (recorder);
+    }
+
+  clutter_main_quit ();
+
   return FALSE;
 }
 
@@ -22,6 +29,15 @@ on_animation_completed (ClutterAnimation *animation)
   g_timeout_add (1000, stop_recording_timeout, NULL);
 }
 
+static void
+on_stage_realized (ClutterActor *stage,
+                   gpointer      data)
+{
+  recorder = shell_recorder_new (CLUTTER_STAGE (stage));
+  shell_recorder_set_filename (recorder, "test-recorder.ogg");
+  shell_recorder_record (recorder);
+}
+
 int main (int argc, char **argv)
 {
   ClutterActor *stage;
@@ -86,13 +102,14 @@ int main (int argc, char **argv)
                                     "y", 240.0,
                                     NULL);
 
-  recorder = shell_recorder_new (CLUTTER_STAGE (stage));
-  shell_recorder_set_filename (recorder, "test-recorder.ogg");
+  g_signal_connect_after (stage, "realize",
+                          G_CALLBACK (on_stage_realized), NULL);
 
   clutter_actor_show (stage);
 
-  shell_recorder_record (recorder);
   clutter_main ();
 
+  g_object_unref (stage);
+
   return 0;
 }